define(function(require){
	var main =require('/static/main.js');
	var m = new main();
	function Cont(){
		this.Fun._init();
	}
	Cont.prototype.Fun = {
		_init:function(){
		    this.getdetialData();
			this.bindEvent();
		},
		bindEvent:function(){
			
		},
		getdetialData:function(){
			var _this = this;
			$.ajax({
                type: "POST",
                url: "/subordinate/get-detial",
                dataType: "json",
                data:{MytipId:$_GET['id']},
                success: function (ret) {
                   var ret = ret.Model
                   var per = ret.Percent  ? ret.Percent : 0
                   var done = ret.TotalDoneCount < 0 ? '0' : ret.TotalDoneCount
                   var view = ret.TotalPageView < 0 ? '0' : ret.TotalPageView
                   var sale = ret.TotalSalesVolume < 0 ? '0' : ret.TotalSalesVolume

                   $('.change').html(parseInt(ret.Percent));
                   $('.order').html(done);
                   $('.view').html(view);
                   $('.shell').html(sale);
                   jQuery(document).ready(function($) {
				        $('.counter').counterUp({
				            delay: 100,
				            time: 1200
				        });
				    });
            	   var data = _this.getList(12,ret.MonthList);
            	   _this.getDetialStyle(data);
                }
            });
		},
		getDetialStyle:function(data){
			var count = 7;
		    var option2 = {
		        tooltip: {
		            trigger: 'axis'
		        },
		        xAxis: {
		            type: 'category',
		            boundaryGap: false,
		            data:data.dateList,
		        },
		        yAxis: {
		            type: 'value',
		        },
		        series: [
		            {
		                name:'绩效',
		                type:'line',
		                markPoint: {
		                    data: [
		                        {type: 'max', name: '最大值'},
		                        {type: 'min', name: '最小值'}
		                    ]
		                },
		                data:data.dataList
		            }
		        ]
		    };
		    var chart2 = document.getElementById('echart2');
		    var echart2= echarts.init(chart2,'customed');
		    echart2.setOption(option2);
		},
		getList:function(count,data){
            var dateList = [1,2,3,4,5,6,7,8,9,10,11,12];
            var dataList = [];
            for(var i = 0; i <= 12; i++){
                var Count2 = 0;
                $.each(data,function(k,v){
                    if(i == parseInt(v.EachMonth)){
                    	Count2 = data[k].MonthSaleroom;
                    }
                });
                dataList.push(Count2);
            }
            var JsonData = {
                dateList:dateList,
                dataList:dataList,
            }
           return JsonData;
        }

	}
	var a = new Cont();

})